package com.example.wufan.broadnotifyttest_425wf;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Switch;

public class MainActivity extends AppCompatActivity {
  private EditText editText;
    private Button btsend,btnotify;
    private String UNIQUE_STRING="com.example.wufan.broadnotifytest_425wufan";

    private View.OnClickListener listener=new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch(v.getId()){
                case R.id.button://发送广播
                    Intent intent=new Intent(UNIQUE_STRING);
                    intent.putExtra("para2",editText.getText().toString());
                    sendBroadcast(intent);
                    break;
                case  R.id.button2://清楚
                    MyReceiver.manage.cancel(MyReceiver.notiftID);
                    break;

            }

        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    private void init() {
        editText=(EditText)findViewById(R.id.editText);
        btsend=(Button)findViewById(R.id.button);
        btnotify=(Button)findViewById(R.id.button);

        btsend.setOnClickListener(listener);
        btnotify.setOnClickListener(listener);

    }
}
